﻿using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media.Imaging;

namespace DiagnosticCenter.ViewModel
{
    public partial class uiAnswerSelect : UserControl
    {
        public int Type { get; set; }

        public uiAnswerSelect()
        {
            InitializeComponent();
        }

        public void SetAnswerType(int type, bool hasimage)
        {
            switch (type)
            {
                case 1:
                    if (hasimage)
                    {
                        listAnswer.ItemTemplate = (DataTemplate)XamlReader.Load(
                            @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
                                <StackPanel Orientation=""Horizontal"">
                                  <RadioButton Margin=""5,5,0,0"" GroupName=""radioAnswer"" IsChecked=""{Binding IsSelected, Mode=TwoWay}""/>
                                  <Image Source=""{Binding Image}"" Width=""32"" Margin=""5,0,0,0""  />
                                </StackPanel>
                              </DataTemplate>");
                    }
                    else
                    {
                        listAnswer.ItemTemplate = (DataTemplate)XamlReader.Load(
                            @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
                                <StackPanel Orientation=""Vertical"">
                                  <RadioButton Content=""{Binding AnswerText}"" Margin=""5,5,0,0"" GroupName=""radioAnswer"" IsChecked=""{Binding IsSelected, Mode=TwoWay}""/>
                                </StackPanel>
                              </DataTemplate>");
                    }
                    break;
                case 2:
                    if (hasimage)
                    {
                        listAnswer.ItemTemplate = (DataTemplate)XamlReader.Load(
                            @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
                                <StackPanel Orientation=""Horizontal"">
                                  <CheckBox Margin=""5,5,0,0"" IsChecked=""{Binding IsSelected, Mode=TwoWay}""/>
                                  <Image Source=""{Binding Image}"" Width=""32"" Margin=""5,0,0,0"" />
                                </StackPanel>
                              </DataTemplate>");
                    }
                    else
                    {
                        listAnswer.ItemTemplate = (DataTemplate)XamlReader.Load(
                            @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
                                <StackPanel Orientation=""Vertical"">
                                  <CheckBox Content=""{Binding AnswerText}"" Margin=""5,5,0,0"" IsChecked=""{Binding IsSelected, Mode=TwoWay}""/>
                                </StackPanel>
                              </DataTemplate>");
                    }
                    break;
            }
        }
    }
}
